var app=angular.module('dzsw', ['pagination']);//定义模块
app.controller('brandController' ,function($scope,$controller,$http){
    $controller('baseController',{$scope:$scope});//继承
    //分页
    $scope.findPage=function(pageNum,pageSize){
        $http.post('../tbBrand/list.do?pageSize='+pageSize+"&pageNum="+pageNum,$scope.searchEntity).success(
            function(response){
                $scope.list=response.records;
                $scope.paginationConf.totalItems=response.total;//更新总记录数
            }
        );
    }
    //保存方法
    $scope.save=function () {
        $scope.entity.jianjie=editor.html();
        $http.post("../tbBrand/save.do?ahids="+$scope.fxselects,$scope.entity).success(
            function(response){
                if(response.success){
                    editor.html('');
                    $scope.reloadList();
                } else{
                    alert(response.errmsg);
                }
            }
        )
    }
    //回显getById
    $scope.getById=function (id) {
       /*sha = new jsSHA("SHA-1","TEXT",{numRounds:1});
        sha.update("123");//用手机号和卡号生成数字摘要
        alert(sha.getHash("HEX")+"====")*/
        $http.get("../tbBrand/getById.do?id="+id).success(
            function(response){
                $scope.entity=response;
                editor.html($scope.entity.jianjie);
            }
        )
    }
    //删除
    $scope.detebth=function () {
        if(confirm("您确定要删除吗？")){
            $http.get("../tbBrand/deletbth.do?ids="+$scope.selectIds).success(
                function(response){
                    if(response.success){
                        $scope.reloadList();
                    } else{
                        alert(response.errmsg);
                    }
                }
            )
        }
    }
    //获取所有类型
    $scope.getTypes=function () {
        $http.get("../tbBrand/getTypes.do").success(
            function(response){
                $scope.typelist=response;
            }
        )
    }
    //获取所有爱好
    $scope.getTAihaoKeys=function () {
        $http.get("../tbBrand/getTAihaoKeys.do").success(
            function(response){
                $scope.aihaolist=response;
                console.log($scope.aihaolist);
            }
        )
    }
    //获取当前登录用户名
    $scope.getName=function () {
        $http.get("../tbBrand/name.do").success(
            function(response){
                $scope.loginName=response.loginName;
            }
        )
    }

});